<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>打印当前时间  比如：周四[11:15:8]</title>
	</head>
	<body>
		<p></p>
		<script type="text/javascript">
			const week = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
			// 获取元素标签
			const p = document.querySelector('p');
			// 定时器，每1秒一下
			setInterval(function() {
				const time = new Date();
				const hour = time.getHours(); // 获取小时
				const minute = time.getMinutes(); // 获取分钟
				const second = time.getSeconds(); // 获取秒
				const period = time.getDay();// 获取日期
				p.innerHTML = week[period] + '[' + hour + ':' + minute + ':' + second + ']'
			}, 1000)
		</script>
	</body>
</html>
